package com.cci.kangdao.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

import java.util.List;
import java.util.Map;

/**
 * @author linjiankun
 * @date 2022/6/10 9:49
 */
@MapperScan
public interface ECJVServiceBookDao {

    //获取服务手册目录
    @Select("select ID as BookDirid,BookDirname as BookDirname from ECJV_ServiceBookDir_T where Flag = 0 and\n" +
            "ID in (select distinct ServiceBookDirID from ECJV_Handbook_T where DicID = #{ecjvEngineTypeDInt} and Type = #{ecjvServiceBookConfigDInt} and Flag = 0)\n" +
            "order by Systime")
    List<Map<String,Object>> getECJVServiceBookCatalogue(Map<String,Object> map);

    //获取维护操作手册 维修手册 故障诊断手册pdf手册
    @Select("select a.IsLogo,b.FileName,b.FileUrl,b.TolNum,b.ID as ServiceBookId from ECJV_Handbook_T a\n" +
            "inner join ECJV_HandbookDetail_T b on a.ID = b.HandbookID\n" +
            "where a.DicID = #{ecjvEngineTypeDInt} and a.Type = #{ecjvServiceBookConfigDInt} and a.ServiceBookDirID = #{bookDirid} and a.Flag = 0 and b.Flag = 0\n" +
            "order by b.CreateTime")
    List<Map<String,Object>> getECJVServiceBookList1(Map<String,Object> map);

    //获取电路图 工具清单pdf手册
    @Select("select IsLogo,FileName,FileUrl,TolNum,ID as ServiceBookId from ECJV_CircuitDiagram_T where Flag = 0 and DicID = #{dicID} and Type = #{ecjvServiceBookConfigDInt} order by CreateTime")
    List<Map<String,Object>> getECJVServiceBookList2(Map<String,Object> map);


    //更新pdf手册阅读次数
    @Update("update ${tableName} set TolNum = TolNum+1 where ID = #{serviceBookId}")
    int updateHandTolNum(@Param("tableName")String tableName,@Param("serviceBookId") long serviceBookId);
}
